package com.ygxsk.carhome.ui.adapter;

import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import com.bumptech.glide.Glide;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;
import com.ygxsk.carhome.R;
import com.ygxsk.carhome.response.RunManGroupHeadOrTeamCheck;
import com.ygxsk.carhome.utils.CommUtils;

import java.util.List;

/**
 * Autuhor:Administrator
 * Time:2023-03-10  21:20
 * Description: this is 合同签约
 */
public class SignatureGroupHeadManMemberAdapter extends BaseQuickAdapter<RunManGroupHeadOrTeamCheck, BaseViewHolder> {

    public SignatureGroupHeadManMemberAdapter(int layoutResId, @Nullable List<RunManGroupHeadOrTeamCheck> data) {
        super(layoutResId, data);

        addChildLongClickViewIds(R.id.linearlayoutcontentphone);

    }

    @Override
    protected void convert(@NonNull BaseViewHolder baseViewHolder, RunManGroupHeadOrTeamCheck runManGroupHeadOrTeamCheck) {

        if (runManGroupHeadOrTeamCheck != null) {

            String trueName = runManGroupHeadOrTeamCheck.getTrueName();

            //岗位名称
            String jobName = runManGroupHeadOrTeamCheck.getJobName();

            //手机号信息是如果岗位名称没有就取出手机号信息
            String phoneNumber = runManGroupHeadOrTeamCheck.getPhone();

            //头像信息
            String imageUrl = runManGroupHeadOrTeamCheck.getPhotoUrl();

            //是否被勾中
//            int isChecked = runManGroupHeadOrTeamCheck.getIsChecked();

            //findview
            //人员的头像
            ImageView imageViewPersonBankRankRunMan = (ImageView) baseViewHolder.findView(R.id.imageviewpersonbankrankrunman);
            TextView textViewNameInHeadMan = (TextView) baseViewHolder.findView(R.id.textviewnameinheadman);
            //中间的分割线条
//            TextView textViewSplitHeadMan = (TextView) baseViewHolder.findView(R.id.textviewsplitheadman);

            TextView textViewPersonInStaionName = (TextView) baseViewHolder.findView(R.id.textviewpersoninstaionname);
            //被选中的图片内容
//            CheckBox checkBoxInHeadMan = (CheckBox) baseViewHolder.findView(R.id.checkboxinheadman);
            //底部的一条横向，最后一条数据的时候 是隐藏的
            TextView textViewLineInHeadMan = (TextView) baseViewHolder.findView(R.id.textviewlineinheadman);

            //包裹手机号的内容
//            LinearLayout linearlLayoutContentPhone = (LinearLayout)baseViewHolder.findView(R.id.linearlayoutcontentphone);


            //真实名字
            CommUtils.setText(textViewNameInHeadMan, trueName);
            //岗位名称
            CommUtils.setText(textViewPersonInStaionName, phoneNumber);

            //加载图片:因为这里是png图片，所以这里用png占位
            Glide.with(getContext())//
                    .load(imageUrl)//
                    .centerInside()//
                    .error(R.drawable.vector_personl)//
                    .placeholder(R.drawable.iconmri)//
                    .fallback(R.drawable.vector_personl)//
                    .into(imageViewPersonBankRankRunMan);//

            //如果工作名称 岗位名称是空，那么不展示分隔符号
//            if (TextUtils.isEmpty(jobName)) {
//                textViewSplitHeadMan.setVisibility(View.GONE);
//            } else {
//                textViewSplitHeadMan.setVisibility(View.VISIBLE);
//            }

            //最后一条数据隐藏
            if (getItemPosition(runManGroupHeadOrTeamCheck) == getData().size() - 1) {
                textViewLineInHeadMan.setVisibility(View.GONE);
            } else {
                textViewLineInHeadMan.setVisibility(View.VISIBLE);
            }

//            if (isChecked == 1) {//表示选中
//                checkBoxInHeadMan.setChecked(true);
//            } else if (isChecked == 0) {
//                checkBoxInHeadMan.setChecked(false);
//            }

        }
    }
}
